open Type;
(*{{{ Агенты*)
class actor weight (name:string) =
  object(self)

  method name   :string = name;
  method weight :int = weight; 

  method move_delay = 
    match self#state with
    [ `Run -> 0.05
    | `Walk -> 0.1
    | _ -> assert False
    ];

  value mutable state:Class.state = `Walk;
  method state = state;
  method set_state (s:Class.state) = state := s;

  value max_stamina:int = 5; 
  value mutable stamina:int = 10;
  method dec_stamina damage = 
  (
    stamina := stamina - damage;
    if stamina <= 0 
    then
    (
      stamina := 0;
      self#set_state `Die;
    )
    else ();
  );

  initializer ();

  value mutable target = (28,28);
  method target = target;
  method set_target t = 
  (
    self#set_path [];
    target := t;
  );

  value mutable path:list (int*int) = [];
  method set_path p = path := p;
  method path = path;
  method p_print =
    (
      List.iter (fun (x,y) -> Printf.printf "(%dx%d) " x y) path;
      Printf.printf "\n"
    );

  method do_step p = 
    match self#path with
    [ [hd::tl] when hd = p -> self#set_path tl
    | _ -> assert False
    ];

  method attack_me (a:actor) = 
  (
    a#set_state `Run;
    self#dec_stamina 1;
    self#set_state `Stun;
  );

end;
(*}}}*)



  
